using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using NTTHAO.Common.BL;
using NTTHAO.CommonWeb;

public partial class admin_webparts_Common_ProfileManagement : System.Web.UI.UserControl
{
    public NTTHAO.Common.BL.AdminUser _EditingUser = null;
    public string _ErrorMessage = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        this.btnSave.Text = LanguageUtility.GetLanguageText("SAVE", Session);

        if (!IsPostBack)
        {
            string strAction = Request.QueryString["action"];
            string strID = Request.QueryString["id"];

            NTTHAO.Common.BL.AdminUser loggedUser;
            try
            {
                loggedUser = new NTTHAO.Common.BL.AdminUser(Context.User.Identity.Name);
                if (loggedUser.ID < 1)
                {
                    Response.Redirect("?");
                    return;
                }
            }
            catch (Exception)
            {
                Response.Redirect("?");
                return;
            }
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strID = Request.QueryString["id"];

        NTTHAO.Common.BL.AdminUser loggedUser = new NTTHAO.Common.BL.AdminUser(Context.User.Identity.Name);
        if (loggedUser.ID < 1)
        {
            Response.Redirect("?");
            return;
        }

        try
        {
            NTTHAO.Common.BL.AdminUser adminUser = new NTTHAO.Common.BL.AdminUser(Context.User.Identity.Name);

            if (encryptedPassword.Value.Length > 0)
            {
                adminUser.Password = encryptedPassword.Value.Trim();
            }
            adminUser.Update();
            Response.Redirect("?");
        }
        catch (Exception)
        {
            Response.Redirect("?");
        }
    }
}
